<?php


namespace app\api\controller;


use app\common\controller\Api;
/**
 * 行业/工作委员会
 */
class Committee extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];



    /**
     * 获取分类列表
     */
    public function getCatList(\app\common\model\committee\CommitteeCatModel $CommitteeCatModel){
        $pid = $this->request->request('pid');
        $data = $CommitteeCatModel->getList($pid);
        $this->result($data['msg'], $data['data'], $data['code']);
    }


    /**
     * 获取分类详情
     */
    public function getCatDetail(\app\common\model\committee\CommitteeCatModel $CommitteeCatModel){
        $id = $this->request->request('id');
        if(empty($id)){
            $this->error('请求参数错误');
        }
        $data = $CommitteeCatModel->getDetail($id);
        $this->result($data['msg'], $data['data'], $data['code']);
    }



    /**
     * 获取风采分页列表
     * @ApiMethod GET
     * @param string $cid 分类ID
     */
    public function getMemberPageList(\app\common\model\committee\CommitteeMemberModel $CommitteeMemberModel){
        $cid = $this->request->request('cid');
        if(empty($cid)){
            $this->error('请求参数错误');
        }
        $user_id = $this->auth->id;
        $page = $this->request->request('page');
        $limit = $this->request->request('limit');
        $data = $CommitteeMemberModel->getPageList($cid, $user_id, $page, $limit);
        $this->result($data['msg'], $data['data'], $data['code']);
    }



    /**
     * 获取新闻分页列表
     * @ApiMethod GET
     * @param string $cid 分类ID
     */
    public function getNewsPageList(\app\common\model\committee\CommitteeNewsModel $CommitteeNewsModel){
        $cid = $this->request->request('cid');
        if(empty($cid)){
            $this->error('请求参数错误');
        }
        $user_id = $this->auth->id;
        $page = $this->request->request('page');
        $limit = $this->request->request('limit');
        $data = $CommitteeNewsModel->getPageList($cid, $user_id, $page, $limit);
        $this->result($data['msg'], $data['data'], $data['code']);
    }



    /**
     * 获取新闻详情
     */
    public function getNewsDetail(\app\common\model\committee\CommitteeNewsModel $CommitteeNewsModel){
        $id = $this->request->request('id');
        if(empty($id)){
            $this->error('请求参数错误');
        }
        $data = $CommitteeNewsModel->getDetail($id);
        $this->result($data['msg'], $data['data'], $data['code']);
    }

}